package com.demo.k8s.controller;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试在istio服务网格请求外部服务。
 * istio安装时默认是允许所有服务都可以请求外部服务
 */
@Slf4j
@RestController
public class OutboundController {

    @GetMapping("/k8s/https/outbound")
    public int reqHttpsOutbound() {
        HttpResponse response = HttpRequest.get("https://www.baidu.com/").execute();
        int status = response.getStatus();
        log.info("status:{}", status);
        return status;
    }
}
